local skill = fk.CreateSkill{
  name = "tea__hongcui",
}
local U = require "packages/utility/utility"
---@type ViewAsSkillSpec
local hongcui = {
  anim_type = "special",
  pattern = ".|.|.|.|.|trick",
  prompt = "#tea__hongcui-prompt",
  interaction = function(self, player)
    local all_names = Fk:getAllCardNames("t")
    local names = player:getViewAsCardNames("tea__hongcui", all_names, player:getCardIds("h"))
    if #names > 0 then
      return UI.CardNameBox { choices = names, all_choices = all_names }
    end
  end,
  card_filter = function(self, player, to_select, selected)
    return true
  end,
  view_as = function(self, player, cards)
    if not self.interaction.data then return end
    local card = Fk:cloneCard(self.interaction.data)
    local name_len = Fk:translate(card.trueName, "zh_CN"):len()
    local selected_len = 0
    for _, id in ipairs(cards) do
      local n = Fk:translate(Fk:getCardById(id).trueName, "zh_CN"):len()
      selected_len = selected_len + n
    end
    if selected_len ~= name_len then return end
    card.skillName = self.name
    card:addSubcards(cards)
    return card
  end,
  before_use = function(self, player, use)
    if #(use.card.subcards or {}) >= 2 then
      player:drawCards(1, self.name)
    end
  end,
  enabled_at_play = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryTurn) == 0
  end,
  enabled_at_response = function(self, player, response)
    return not response and player:usedSkillTimes(self.name, Player.HistoryTurn) == 0
  end,
}
skill:addEffect("viewas", hongcui)
return skill